#ifndef TESTWIDGET_H
#define TESTWIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>
#include "RSA/rsa.h"
extern "C" {
#include "SHA256/sha256.h"
}



namespace Ui {
class testWidget;
}

class TestWidget : public QWidget
{
    Q_OBJECT

public:
    explicit TestWidget(QWidget *parent = nullptr);
    ~TestWidget();



private slots:
    void on_btnOpen_clicked(bool checked);

    void on_btnSend_clicked(bool checked);

    void serialPortReadyRead();

    void serialTimerTimeoutHandle( );

    void on_btnRsaSend_clicked(bool checked);

private:
    Ui::testWidget *ui;
    QSerialPort *serialPort;
    QTimer *serialTimer;
    void serialPortInit();
    bool isPrintableAscii(const QByteArray &data);
    SHA256_CTX ctx;
    key_t pub = { 0 };
    key_t priv = { 0 };
};

#endif // TESTWIDGET_H
